<?php
	include_once dirname(dirname(dirname(__FILE__))).'/inc/bootConfig.php';
	include_once '../checkLogin.php';
	$id = getRequest('id');
	$edit = getRequest('e');
	if(empty($id) || empty($edit)){
		jstop('参数错误');
	}
	
	if('del' == $edit){
		$child = Module_Select::getSonModuleById($id);
		if(is_array($child) && count($child)>0){
			jstop('该模块存在子模块，请先删除子模块后再进行删除');
		}
		if(Module_Edit::deleteMod($id)){
			Cache_Filecache::delFileCache();
			header('Location:addModule.php');
			exit;
		}
		jstop('系统繁忙，请重试');
	}
	
	$module = Module_Select::getModuleInfoById($id);
	$module = $module[0];
	if($module['z_belong']>0){
		$pmod = Module_Select::getModuleInfoById($module['z_belong']);
		$pmod = $pmod[0];
	}
	if(isset($_POST['editsubmit'])){
		
		$upd['z_name'] = $_POST['namenew'];
		$upd['z_grade'] = $_POST['grade'];
		$upd['z_mark'] = addslashes(sy2dy($_POST['remark']));
		$upd['z_updtime'] = date('Y-m-d H:i:s');
		$upd['z_upduser'] = $_SESSION['username'];
		$upd['z_showmod'] = $_POST['showmod'];
		if(Module_Edit::update('zjx_module_admin',$upd,'z_id='.$id)){
			Cache_Filecache::delFileCache();
			showmsgbox('修改成功','addModule.php');
			exit;
		}
		jstop('系统繁忙，请重试');
	}
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑模块</title>
<link rel="stylesheet" type='text/css' href='../Public/static/css/admincp/admincp.css'>
</head>
<body>
<table id="tips" class="tb tb2 ">
	<tbody>
		<tr>
			<th class="partition">技巧提示</th>
		</tr>
		<tr>
			<td class="tipsblock">
			<ul id="tipslis">
				<li>以下设置没有继承性，即仅对当前版块有效，不会对下级子版块产生影响。</li>
			</ul>
			</td>
		</tr>
	</tbody>
</table>
<form action='' method='post'>
<table class="tb tb2 ">
	<tbody>
		<tr>
			<td class="td27" colspan="2">模块名称:</td>
		</tr>
		<tr class="noborder">
			<td class="vtop rowform"><input type="text" class="txt" value="<?php echo $module['z_name']?>" name="namenew"></td>
			<td class="vtop tips2"></td>
		</tr>
		<?php 
			if($module['z_belong']>0){
		?>
		<tr>
			<td class="td27" colspan="2">上级模块名称:</td>
		</tr>
		<tr>
			<td class="td27">
				<select disabled>
					<option value='<?php echo $module['z_belong']?>'><?php echo $pmod['z_name']?></option>
				</select>
			</td>
			<td class="vtop tips2">指本版块所属的模块名称</td>
		</tr>
		<?php 
			}else{
		?>
			<tr>
				<td class="td27" colspan="2">
					模块显示方式:
					<?php echo putselect('showmod', array(2=>'显示',1=>'隐藏',3=>'在脚部隐藏'),$module['z_showmod']);?>
				</td>
			</tr>
		<?php }?>
		<tr>
			<td class="td27" colspan="2">显示顺序:</td>
		</tr>
		<tr class="noborder">
			<td class="vtop rowform">
				<input type='text' name='grade' value="<?php echo !empty($module['z_grade'])?$module['z_grade']:'0'?>">
			</td>
			<td class="vtop tips2">
				在导航及其它模块显示时的顺序，数值越小越靠前
			</td>
		</tr>
		<tr>
			<td class="td27">模块详情:</td>
			<td class="vtop tips2">
				对模块的描述，越详细越好，用于显示在页面右边的说明中
			</td>
		</tr>
		<tr class="noborder">
			<td class="vtop" colspan='100'>
				<INPUT id=content style="DISPLAY: none" type=hidden name="remark" value="<? echo $module['z_mark'] ?>">
				<INPUT id=content___Config style="DISPLAY: none" type=hidden> 
				<IFRAME id=content___Frame src="../Public/static/FCK/editor/fckeditor.html?InstanceName=remark&Toolbar=Default" frameBorder=0 width=70% scrolling=no height=400> 
				</IFRAME>
			</td>
			
		</tr>
		<tr>
			<td colspan="15">
			<div class="fixsel"><input type="submit" value="提交"
				title="按 Enter 键可随时提交你的修改" name="editsubmit"
				id="submit_detailsubmit" class="btn">
			<input type="button" value="返回" title="按 Enter 键可随时提交你的修改" name="" onclick="location.href='addModule.php'" class="btn">	
			</div>
			</td>
		</tr>
		<script type="text/JavaScript">_attachEvent(document.documentElement, 'keydown', function (e) { entersubmit(e, 'detailsubmit'); });</script>
	</tbody>
</table>
</form>
</body>
</html>